
import UIKit
import SnapKit

class LoadingView: UIView {
    
    private lazy var showView: UIActivityIndicatorView = {
        let v = UIActivityIndicatorView.init(style: .white)
        v.isHidden = false
        v.startAnimating()
        return v
    }()
    
    private lazy var loadLabel: UILabel = {
        let label = UILabel()
        label.text = ""
        label.textColor = .init(white: 1, alpha: 0.5)
        label.font = .setTypeFace(16, type: .medium)
        label.textAlignment = .center
        return label
    }()
    
    init(_ content: String = "", _ alpha: CGFloat) {
        super.init(frame: .zero)
        tag = 7813413
        backgroundColor = .blackComponent(alpha)
        addSubview(showView)
        showView.snp.makeConstraints { make in
            make.center.equalToSuperview()
            make.size.equalTo(CGSize(width: 80.Fit, height: 80.Fit))
        }
        addSubview(loadLabel)
        loadLabel.snp.makeConstraints { make in
            make.top.equalTo(showView.snp.bottom).offset(15.Fit)
            make.leading.trailing.equalToSuperview()
        }
        loadLabel.text = content.isEmpty ? "" : content
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        fatalError("init(_ content: String = 'Loading...', _ alpha: CGFloat) has not been implemented")
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
